package com.xiejr.actuator.socket.proxy;

import com.xiejr.actuator.socket.Topic;
import lombok.Getter;
import lombok.Setter;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @program: socket-actuator-spring-boot-starter
 * @description: 主题式处理器代理
 * @author: xjr
 * @create: 2020-07-13 15:09
 **/
@Setter
@Getter
public class TopicProxy implements InvocationHandler {

    private Topic topic;

    private String beanName;

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        String arg= (String) args[0];
        if (this.beanName.equals(arg)){
            return topic.delivery(arg);
        }
        return null;
    }


}
